<template>
    <div class="footer">
        <div :class="['footer-box',isIOS]">
            <div :class="{isActive:(idx==index)}" v-for="(item,index) in menu" :key="index" @click="activeItem(index)">
                <img :src="index==idx? item.activeUrl : item.url">
                {{item.tab}}
            </div>
        </div>

    </div>
</template>

<script>
    export default {
        name: 'footerItem',
        props: ['idx'],
        data() {
            return {
                isIOS: '',
                system: '',
                menu: [
                    {
                        tab: '客户信息',
                        activeUrl: require('../assets/img/kh_active.png'),
                        url: require('../assets/img/kh_default.png'),
                        routerUrl: '/',
                    },
                    {
                        tab: '分类',
                        activeUrl: require('../assets/img/class_active.png'),
                        url: require('../assets/img/class_default.png'),
                        routerUrl: '/classify',
                    },
                ],
                indexs: '0'
            }
        },
        methods: {
            activeItem(index) {
                this.$router.replace(this.menu[index].routerUrl)
            },
            isAndroidOrIOS() {
                var u = navigator.userAgent, app = navigator.appVersion;
                var isAndroid = u.indexOf('Android') > -1 || u.indexOf('Linux') > -1; //Android终端
                var isIOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); // ios终端
                if (isAndroid) {
                    // 这个是安卓操作系统
                }
                if (isIOS) {
                    // 这个是ios操作系统
                    if (this.system == 'yes') {
                        this.isIOS = 'ios'
                    }
                }
            }
        },
        mounted() {
            this.system = localStorage.getItem('iosOK')
            this.isAndroidOrIOS()
        }
    }
</script>

<style scoped lang="less">
    .footer-box {
        height: 6.5vh;
        border-top: 1px solid #dbdbdb;
        background: #fff;
        display: flex;
        padding: 11px 0;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;

        div {
            flex: 1;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            font-size: 10px;
            color: #999;
        }

        div:first-child {
            position: relative;
        }

        div:first-child:after {
            content: "";
            height: 15px;
            width: 1px;
            border-left: 1px dashed #dcdcdc;
            position: absolute;
            right: 0;
            top: 50%;
            transform: translateY(-50%);
        }

        img {
            width: 19px;
            height: 21px;
        }

        .isActive {
            color: #366cb3;
        }
    }

    .ios {
        bottom: 40px;
    }
</style>
